/**
 * 
 */
package com.yidu.erp.action.BeyondPersonelRole;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yidu.common.SsmMessage;
import com.yidu.erp.model.BeyondPersonelRole;
import com.yidu.erp.service.BeyondPersonelRole.PersonelRoleService;

/**
 * 用户角色Action
 * @author wws
 * @date  2017年10月26日
 */
@Controller
@RequestMapping("personelrole")
public class BeyondPersonelRoleAction {
	
	@Resource
	private PersonelRoleService personelRoleService;
	
	/**
	 * 增加员工角色方法
	 * @param personelrole
	 * @return
	 */
	@RequestMapping("/savepersonelrole")
	@ResponseBody
	public SsmMessage savemanrole(BeyondPersonelRole personelrole){
		SsmMessage message = new SsmMessage();
		System.out.println("进来了BeyondPersonelRoleController增加员工角色方法 ，员工角色id="+personelrole.getPerRoleId()+" 角色id="+personelrole.getRoleId()+"员工id="+personelrole.getStaffId());
		int sc = personelRoleService.deleteByPrimaryKey(personelrole.getStaffId());
		
		int rows = personelRoleService.insertSelective(personelrole);
		System.out.println("增加员工角色成功，rows="+rows);
		if(rows>0){
			message.setState(SsmMessage.SUCCESS);
			message.setMes(SsmMessage.SUCCESS_MES);
		}else{
			message.setState(SsmMessage.ERROR);
			message.setMes(SsmMessage.ERROR_MES);
		}
		return message;
	}
	
	
}
